package com.king.bean

import java.util.Objects

import com.alibaba.fastjson.annotation.JSONField
import com.alibaba.fastjson.serializer.ToStringSerializer

import scala.beans.BeanProperty

/**
 * @Author: KingWang
 * @Date: 2022/2/12  
 * @Desc:
 *
 *       Scala 有主构造函数，和辅助构造函数
 *       主构造函数直接在类名后面加，
 *       辅助构造函数在类内部使用this()
 **/
class OrderWide(orderInfo:OrderInfo,orderDetail:OrderDetail) extends Serializable {

  @BeanProperty var detail_id:Long = _
  @BeanProperty var order_id:Long = _
  @BeanProperty var sku_id:Long = _

  @BeanProperty var order_price:java.math.BigDecimal = _
  @BeanProperty var sku_num:String = _
  @BeanProperty var sku_name:String = _
  @BeanProperty var province_id:Long = _
  @BeanProperty var order_status:String = _
  @BeanProperty var user_id:Long = _

  @BeanProperty var total_amount:java.math.BigDecimal = _
  @BeanProperty var activity_reduce_amount:java.math.BigDecimal = _
  @BeanProperty var coupon_reduce_amount:java.math.BigDecimal = _
  @BeanProperty var original_total_amount:java.math.BigDecimal = _
  @BeanProperty var feight_fee:java.math.BigDecimal = _

  @BeanProperty var split_feight_fee:java.math.BigDecimal = _
  @BeanProperty var split_activity_amount:java.math.BigDecimal = _
  @BeanProperty var split_coupon_amount:java.math.BigDecimal = _
  @BeanProperty var split_total_amount:java.math.BigDecimal = _

  @BeanProperty var expire_time:String = _
  @BeanProperty var create_time:String = _
  @BeanProperty var operate_time:String = _
  @BeanProperty var create_date:String = _
  @BeanProperty var create_hour:String = _

  //省份维度表
  @BeanProperty var province_name:String = _
  @BeanProperty var province_area_code:String = _
  @BeanProperty var province_iso_code:String = _
  @BeanProperty var province_3166_2_code:String = _

  //用户维度
  @BeanProperty var user_age:Int = _
  @BeanProperty var user_gender:String = _

  //商品维度
  @BeanProperty var spu_id:Long = _
  @BeanProperty var tm_id:Long = _
  @BeanProperty var category3_id:Long = _
  @BeanProperty var spu_name:String = _
  @BeanProperty var tm_name:String = _
  @BeanProperty var category3_name:String = _



  mergeOrderInfo(orderInfo)
  mergeOrderDetail(orderDetail)


  def mergeOrderInfo(orderInfo: OrderInfo) = {
    if(Objects.nonNull(orderInfo)){
      order_id = orderInfo.id
      order_status = orderInfo.order_status
      create_time = orderInfo.create_time
      create_date = orderInfo.create_date
      create_hour = orderInfo.create_hour
      activity_reduce_amount = orderInfo.activity_reduce_amount
      coupon_reduce_amount = orderInfo.coupon_reduce_amount
      original_total_amount = orderInfo.original_total_amount
      feight_fee = orderInfo.feight_fee
      total_amount = orderInfo.total_amount
      province_id = orderInfo.province_id
      user_id = orderInfo.user_id
    }
  }

  def mergeOrderDetail(orderDetail: OrderDetail) = {
    if(Objects.nonNull(orderDetail)){
      detail_id = orderDetail.id
      sku_id = orderDetail.sku_id
      sku_name = orderDetail.sku_name
      order_price = orderDetail.order_price
      sku_num = orderDetail.sku_num
      split_activity_amount = orderDetail.split_activity_amount
      split_coupon_amount = orderDetail.split_coupon_amount
      split_total_amount = orderDetail.split_total_amount
    }
  }





}
